home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / etc / init.d / ufw < prev    next >
Encoding:
Text File  |  2009-04-03  |  2.0 KB  |  85 lines

  1. #!/bin/sh -e
  2.  
  3. ### BEGIN INIT INFO
  4. # Provides:          ufw
  5. # Required-Start:    mountall
  6. # Required-Stop:     
  7. # Default-Start:     S
  8. # Default-Stop:      
  9. # Short-Description: start firewall
  10. ### END INIT INFO
  11.  
  12. PATH="/sbin:/bin:/usr/sbin:/usr/bin"
  13.  
  14. [ -x /usr/sbin/ufw ] || exit 0
  15.  
  16. . /lib/lsb/init-functions
  17.  
  18. for s in "/usr/share/ufw/ufw-init-functions" "/etc/ufw/ufw.conf" "/etc/default/ufw" ; do
  19.     if [ -s "$s" ]; then
  20.         . "$s"
  21.     else
  22.         log_failure_msg "Could not find $s (aborting)"
  23.         exit 1
  24.     fi
  25. done
  26.  
  27. error=0
  28. case "$1" in
  29. start)
  30.     if [ "$ENABLED" = "yes" ] || [ "$ENABLED" = "YES" ]; then
  31.         log_action_begin_msg "Starting firewall:" "ufw"
  32.         output=`ufw_start` || error="$?"
  33.         if [ "$error" = "0" ]; then
  34.             log_action_cont_msg "Setting kernel variables ($IPT_SYSCTL)"
  35.         fi
  36.         if [ ! -z "$output" ]; then
  37.             echo "$output" | while read line ; do
  38.                 log_action_cont_msg "$line"
  39.             done
  40.         fi
  41.     else
  42.         log_action_begin_msg "Skip starting firewall:" "ufw (not enabled)"
  43.     fi
  44.     log_action_end_msg $error
  45.     exit $error
  46.     ;;
  47. stop)
  48.     if [ "$ENABLED" = "yes" ] || [ "$ENABLED" = "YES" ]; then
  49.         log_action_begin_msg "Stopping firewall:" "ufw"
  50.         output=`ufw_stop` || error="$?"
  51.         if [ ! -z "$output" ]; then
  52.             log_action_cont_msg "$output"
  53.         fi
  54.     else
  55.         log_action_begin_msg "Skip stopping firewall:" "ufw (not enabled)"
  56.     fi
  57.     log_action_end_msg $error
  58.     exit $error
  59.     ;;
  60. restart|force-reload)
  61.     log_action_begin_msg "Reloading firewall:" "ufw"
  62.     output=`ufw_reload` || error="$?"
  63.     if [ ! -z "$output" ]; then
  64.         log_action_cont_msg "$output"
  65.     fi
  66.     log_action_end_msg $error
  67.     exit $error
  68.     ;;
  69. status)
  70.     output=`ufw_status` || error="$?"
  71.     if [ ! -z "$output" ]; then
  72.         log_action_cont_msg "$output"
  73.     fi
  74.     log_action_end_msg $error
  75.     exit $error
  76.     ;;
  77. *)
  78.     echo "Usage: /etc/init.d/ufw {start|stop|restart|force-reload|status}"
  79.     exit 1
  80.     ;;
  81. esac
  82.  
  83. exit 0
  84.  
  85.